<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class popup extends Admin_My_Controller {
    public function __construct() {
        parent::__construct();
    }

    public function city() {
        $this->load->model('popup/city_model');

        $data = array();

        $field_name = array("cityid", "cityname");
        $field_title = array("Kode Kota", "Nama Kota");
        $field_type = array("text", "text");

        $filter_panel = new FilterPanel(base_url(). '/index.php', $field_name, $field_title, $field_type);

        $whr = $filter_panel->getFilterString();
        $pos1 = strpos($whr, "like");

        if ($pos1 != 0) {
            $replace = substr($whr, $pos1, strlen($whr) - 1);
            $arrSearch = array("'||('", "')||'", "((", "))");
            $arrReplace = array("", "", "(", ")");
            $srtReplace = str_replace($arrSearch, $arrReplace, $replace);

            $whr = substr_replace($whr, $srtReplace, $pos1, strlen($whr) - $pos1);
        }

        $whr = $whr == "" ? "" : " WHERE ".$whr;

        $data['post'] = $this->getPostInfo();
        $resultSet = $this->city_model->getCity($whr, PAGES_LIMIT,$data['post']['offset']);
        $resultSetAll = $this->city_model->getCityAll($whr);
        $data['row'] = $resultSet->num_rows();
        $data['data'] = $resultSet->result();
        $data['fp'] = $filter_panel->drawfilterpanel();
        $data['fp2'] = $filter_panel->drawfilterpanelsingle();

        $data['paging'] = $this->paging->createPage($resultSetAll->num_rows(), $data['post']['offset'], PAGES_LIMIT, $data['post']['nextPage'], 10, $data['post']['colPage']);

        $this->log_event = "Membuka popup daftar kota";

        $this->loadMenuHeaderPopup('popup/city', $data);
    }

    public function divisi_karyawan() {
        $this->load->model('popup/divisi_model');

        $data = array();

        $resultSet = $this->divisi_model->getDivisi();
        $data['result'] = $resultSet->result();
        $data['numRows'] = $resultSet->num_rows();

        $this->log_event = "Membuka popup daftar divisi karyawan";

        $this->loadMenuHeaderPopup('/popup/divisi_karyawan', $data);
    }

    public function karyawan() {
        $this->load->model('popup/karyawan_model');

        $data = array();

        // menentukan filter panel
        $field_name = array("nik", "nama");
        $field_title = array("NIK", "Nama Rekan");
        $field_type = array("text", "text");

        $filter_panel = new FilterPanel(base_url() . 'index.php/', $field_name, $field_title, $field_type);
        $whr = $filter_panel->getFilterString();
        $whr = $whr == "" ? "" : $whr;

        $data['fp'] = $filter_panel->drawfilterpanelsingle();

        $offset = $_REQUEST["os"];
        $nextPage = $_REQUEST["np"];
        $colPage = $_REQUEST["cp"];

        if ($offset == "") {
            $offset = 0;
        }
        if ($nextPage == "") {
            $nextPage = 1;
        }
        if ($colPage == "") {
            $colPage = 1;
        }

        $resulSetAll = $this->karyawan_model->getAllKaryawan($whr);
        $data['numRowsAll'] = $resulSetAll->num_rows();
        $resulSet = $this->karyawan_model->getKaryawan($whr, $offset);
        $data['result'] = $resulSet->result();
        $data['numRows'] = $resulSet->num_rows();

        $data['offset'] = $offset;
        $data['nextPage'] = $nextPage;
        $data['colPage'] = $colPage;

        if ($whr == "") {
            $data['paging'] = $this->paging->createPage($data['numRowsAll'], $offset, PAGES_LIMIT, $nextPage, 10, $colPage);
            $data['rows'] = $data['numRows'];
            $data['data'] = $data['result'];
        }
        else {
            $data['paging'] = $this->paging->createPage($data['numRowsAll'], $offset, PAGES_LIMIT, $nextPage, 10, $colPage);
            $data['rows'] = $data['numRows'];
            $data['data'] = $data['result'];
        }

        $this->log_event = "Membuka popup data karyawan";

        $this->loadMenuHeaderPopup('popup/karyawan', $data);
    }

    public function singgle_item() {
        $this->load->model('popup/item_model');

        $field_name = array("nama_item", "nama_port");
        $field_title = array("Nama Item", "PORT");
        $field_type = array("text", "text");

        $filter_panel = new FilterPanel(base_url() . 'index.php/', $field_name, $field_title, $field_type);
        $whr = $filter_panel->getFilterString();

        $offset = $this->input->get_post('os');
        $nextPage = $this->input->get_post('np');
        $colPage = $this->input->get_post('cp');

        if ($offset == "")
            $offset = 0;

        if ($nextPage == "")
            $nextPage = 1;

        if ($colPage == "")
            $colPage = 1;

        $result = $this->item_model->item_list($whr, PAGES_LIMIT, $offset);
        $numRowsAll = $this->item_model->count_item_list($whr);
        $data = array(
                "rows" => $result->num_rows(),
                "data" => $result->result(),
                "paging" => $this->paging->createPage($numRowsAll, $offset, PAGES_LIMIT, $nextPage, 10, $colPage),
                "offset" => $offset,
                "fp" => $filter_panel->drawfilterpanelsingle()
        );

        $this->log_event = "Membuka popup singgle item";

        $this->loadMenuHeaderPopup('popup/singgle_item', $data);
    }

    public function jenis_kas_penjualan() {        
        $this->load->model('popup/kas_penjualan_model');

        $field_name = array("jkp.nama_jkp", "sjkp.nama_sjkp");
        $field_title = array("Jenis", "Sub Jenis");
        $field_type = array("text", "text");

        $filter_panel = new FilterPanel(base_url() . 'index.php/', $field_name, $field_title, $field_type);
        $whr = $filter_panel->getFilterString();

        $offset = $this->input->get_post('os');
        $nextPage = $this->input->get_post('np');
        $colPage = $this->input->get_post('cp');

        if ($offset == "")
            $offset = 0;

        if ($nextPage == "")
            $nextPage = 1;

        if ($colPage == "")
            $colPage = 1;

        $result = $this->kas_penjualan_model->item_list();
        $numRowsAll = $this->kas_penjualan_model->count_item_list();
        $data = array(
                "rows" => $result->num_rows(),
                "data" => $result->result(),
                "paging" => $this->paging->createPage($numRowsAll, $offset, PAGES_LIMIT, $nextPage, 10, $colPage),
                "offset" => $offset,
                "fp" => $filter_panel->drawfilterpanelsingle()
        );

        $this->log_event = "Membuka popup jenis kas penjualan";

        $this->loadMenuHeaderPopup('popup/jenis_kas_penjualan', $data);
    }

    public function jenis_kas_operasional() {
        $this->load->model('popup/kas_operasional_model');

        $field_name = array("jko.nama_jko", "sjko.nama_sjko");
        $field_title = array("Jenis", "Sub Jenis");
        $field_type = array("text", "text");

        $filter_panel = new FilterPanel(base_url() . 'index.php/', $field_name, $field_title, $field_type);
        $whr = $filter_panel->getFilterString();

        $offset = $this->input->get_post('os');
        $nextPage = $this->input->get_post('np');
        $colPage = $this->input->get_post('cp');

        if ($offset == "")
            $offset = 0;

        if ($nextPage == "")
            $nextPage = 1;

        if ($colPage == "")
            $colPage = 1;

        $result = $this->kas_operasional_model->item_list();
        $numRowsAll = $this->kas_operasional_model->count_item_list();
        $data = array(
                "rows" => $result->num_rows(),
                "data" => $result->result(),
                "paging" => $this->paging->createPage($numRowsAll, $offset, PAGES_LIMIT, $nextPage, 10, $colPage),
                "offset" => $offset,
                "fp" => $filter_panel->drawfilterpanelsingle()
        );

        $this->log_event = "Membuka popup jenis kas operasional";

        $this->loadMenuHeaderPopup('popup/jenis_kas_operasional', $data);
    }

    public function kelompok_user() {
        $this->load->model('popup/kelompok_user_model');

        $data = array();

        $resulSet = $this->kelompok_user_model->getKelompokUser();
        $data['data'] = $resulSet->result();
        $data['rows'] = $resulSet->num_rows();

        $this->log_event = "Membuka popup kelompok user";

        $this->loadMenuHeaderPopup('/popup/kelompok_user', $data);
    }

    public function kota($kode) {
        $this->load->model('popup/kota_model');

        if ($kode == "") {
            echo "<script>location.href='" . base_url() . "index.php/popup/kota/'+parent.parent.getKodePropinsi();</script>";
        }

        $data = array();

        $resultSet = $this->kota_model->getKota($kode);
        $data['result'] = $resultSet->result();
        $data['numRows'] = $resultSet->num_rows();
        $data['provinceName'] = $this->general_model->getScalar('nama_propinsi', 'mt_propinsi', 'id_propinsi', $kode);

        $this->log_event = "Membuka popup kota";

        $this->loadMenuHeaderPopup('popup/kota', $data);
    }

    public function log_user($kode) {
        $this->load->model('popup/log_user_model');

        $data = array();

        $field_name = array("log_time", "log_aktor", "log_event");
        $field_title = array("Waktu", "Pengguna", "Keterangan");
        $field_type = array("timestamp", "text", "text");

        $filter_panel = new FilterPanel(base_url() . 'index.php/', $field_name, $field_title, $field_type);
        $whr = $filter_panel->getFilterString();

        $whr = $whr == "" ? " log_aktor='" . str_replace("%20", " ", $kode) . "'" : $whr;

        $data['fp'] = $filter_panel->drawfilterpanelsingle();

        $offset = $this->input->get_post('os');
        $nextPage = $this->input->get_post('np');
        $colPage = $this->input->get_post('cp');

        if ($offset == "") {
            $offset = 0;
        }

        if ($nextPage == "") {
            $nextPage = 1;
        }

        if ($colPage == "") {
            $colPage = 1;
        }

        $resulSetAll = $this->log_user_model->getLogUserAll($whr);
        $data['numRowsAll'] = $resulSetAll->num_rows();
        $resulSet = $this->log_user_model->getLogUser($whr, $offset);
        $data['result'] = $resulSet->result();
        $data['numRows'] = $resulSet->num_rows();

        $data['offset'] = $offset;
        $data['nextPage'] = $nextPage;
        $data['colPage'] = $colPage;

        if ($whr == "") {
            $data['paging'] = $this->paging->createPage($data['numRowsAll'], $offset, PAGES_LIMIT, $nextPage, 10, $colPage);
            $data['rows'] = $data['numRows'];
            $data['data'] = $data['result'];
        }
        else {
            $data['paging'] = $this->paging->createPage($data['numRowsAll'], $offset, PAGES_LIMIT, $nextPage, 10, $colPage);
            $data['rows'] = $data['numRows'];
            $data['data'] = $data['result'];
        }

        $this->log_event = "Membuka popup log user";

        $this->loadMenuHeaderPopup('popup/log_user', $data);
    }

    public function propinsi() {

        $this->load->model('popup/propinsi_model');

        $data = array();

        $resultSet = $this->propinsi_model->getPropinsi();
        $data['result'] = $resultSet->result();
        $data['numRows'] = $resultSet->num_rows();

        $this->log_event = "Membuka popup propinsi";

        $this->loadMenuHeaderPopup('popup/propinsi', $data);
    }

    public function search() {
        $this->log_event = "Membuka popup search";

        $this->loadMenuHeaderPopup('popup/search');
    }

    public function customer() {
        $this->load->model('popup/customer_model');

        $data = array();

        $field_name = array("nama_customer");
        $field_title = array("Nama Customer");
        $field_type = array("text");


        $filter_panel = new FilterPanel(base_url() . 'index.php/', $field_name, $field_title, $field_type);
        $whr = $filter_panel->getFilterString();


        $resultSet = $this->customer_model->getCustomer($whr);
        $data['result'] = $resultSet->result();
        $data['numRows'] = $resultSet->num_rows();
        $data['fp'] = $filter_panel->drawfilterpanelsingle();

        $this->loadMenuHeaderPopup('/popup/customer', $data);
    }

    public function supplier() {
        $this->load->model('popup/supplier_model');

        $data = array();

        $field_name = array("nama_supplier");
        $field_title = array("Nama Supplier");
        $field_type = array("text");


        $filter_panel = new FilterPanel(base_url() . 'index.php/', $field_name, $field_title, $field_type);
        $whr = $filter_panel->getFilterString();


        $resultSet = $this->supplier_model->getSupplier($whr);
        $data['result'] = $resultSet->result();
        $data['numRows'] = $resultSet->num_rows();
        $data['fp'] = $filter_panel->drawfilterpanelsingle();

        $this->loadMenuHeaderPopup('/popup/supplier', $data);
    }

    public function customer_from_quotation() {
        $this->load->model('popup/customer_model');

        $data = array();
        $kode = $this->input->post("kode", true);

        $resultSet = $this->customer_model->getCustomerFromQuotation($kode);
        $data['result'] = $resultSet->result();
        $data['numRows'] = $resultSet->num_rows();

        $this->loadMenuHeaderPopup('/popup/customer', $data);
    }

    public function vessel() {
        $this->load->model('popup/vessel_model');

        $data = array();

        $resultSet = $this->vessel_model->getVessel();
        $data['result'] = $resultSet->result();
        $data['numRows'] = $resultSet->num_rows();


        $this->loadMenuHeaderPopup('/popup/vessel', $data);
    }

    public function port() {
        $this->load->model('popup/port_model');

        $data = array();

        $resultSet = $this->port_model->getPort();
        $data['result'] = $resultSet->result();
        $data['numRows'] = $resultSet->num_rows();


        $this->loadMenuHeaderPopup('/popup/port', $data);
    }


    public function get_supplier_detil() {
        $this->load->model('popup/supplier_model');

        $kode = $this->input->post("kode", true);
        $row = $this->supplier_model->getDetailSupplier($kode);

        $result = json_encode(array(
                "alamat_komplit"=> $row->alamat_supplier ."\n". $row->kota_supplier."\n".$row->kode_pos_supplier,
                "kontak_komplit"=> $row->telepon_supplier." / ".$row->fax_supplier." / ".$row->email_supplier,
                "alamat_supplier" => $row->alamat_supplier,
                "alamat_detail_supplier" => $row->alamat_detail_supplier,
                "kota_supplier" => $row->kota_supplier,
                "kode_pos_supplier" => $row->kode_pos_supplier,
                "telepon_supplier" => $row->telepon_supplier,
                "fax_supplier"=> $row->fax_supplier,
                "email_supplier"=>$row->email_supplier,
                "attendance"=>$row->attendance,
                "id_supplier"=>$row->id_supplier,
                "nama_supplier"=>$row->nama_supplier
        ));

        if ($_SERVER["REQUEST_METHOD"] == "POST")
            echo $result;
        else
            return $result;
    }

    public function get_customer_detil() {
        $this->load->model('popup/customer_model');

        $kode = $this->input->post("kode", true);
        $row = $this->customer_model->getDetailCustomer($kode);

        $result = json_encode(array(
                "alamat_komplit"=> $row->alamat_customer ."\n". $row->kota_customer."\n".$row->kode_pos_customer,
                "kontak_komplit"=> $row->telepon_customer." / ".$row->fax_customer." / ".$row->email_customer,
                "alamat_customer" => $row->alamat_customer,
                "alamat_detail_customer" => $row->alamat_detail_customer,
                "kota_customer" => $row->kota_customer,
                "kode_pos_customer" => $row->kode_pos_customer,
                "telepon_customer" => $row->telepon_customer,
                "fax_customer"=> $row->fax_customer,
                "email_customer"=>$row->email_customer,
                "attendance"=>$row->attendance,
                "id_customer"=>$row->id_customer,
                "nama_customer"=>$row->nama_customer
        ));

        if ($_SERVER["REQUEST_METHOD"] == "POST")
            echo $result;
        else
            return $result;
    }

    public function get_customer_detil_2() {
        $this->load->model('popup/customer_model');

        $kode = $this->input->post("kode", true);
        $kode = $this->customer_model->get_scalar("SELECT id_customer FROM data_quotation_to_cust WHERE id_quotation = '$kode'", "id_customer");
        $row = $this->customer_model->getDetailCustomer($kode);

        $result = json_encode(array(
                "alamat_komplit"=> $row->alamat_customer ."\n". $row->kota_customer."\n".$row->kode_pos_customer,
                "kontak_komplit"=> $row->telepon_customer." / ".$row->fax_customer." / ".$row->email_customer,
                "alamat_customer" => $row->alamat_customer,
                "alamat_detail_customer" => $row->alamat_detail_customer,
                "kota_customer" => $row->kota_customer,
                "kode_pos_customer" => $row->kode_pos_customer,
                "telepon_customer" => $row->telepon_customer,
                "fax_customer"=> $row->fax_customer,
                "email_customer"=>$row->email_customer,
                "attendance"=>$row->attendance,
                "id_customer"=>$row->id_customer,
                "nama_customer"=>$row->nama_customer
        ));

        if ($_SERVER["REQUEST_METHOD"] == "POST")
            echo $result;
        else
            return $result;
    }

    public function get_supplier_detil_2() {
        $this->load->model('popup/supplier_model');

        $kode = $this->input->post("kode", true);
        $kode = $this->supplier_model->get_scalar("SELECT id_supplier FROM data_po_to_supplier WHERE id_po = '$kode'", "id_supplier");
        $row = $this->supplier_model->getDetailSupplier($kode);

        $result = json_encode(array(
                "alamat_komplit"=> $row->alamat_supplier ."\n". $row->kota_supplier."\n".$row->kode_pos_supplier,
                "kontak_komplit"=> $row->telepon_supplier." / ".$row->fax_supplier." / ".$row->email_supplier,
                "alamat_supplier" => $row->alamat_supplier,
                "alamat_detail_supplier" => $row->alamat_detail_supplier,
                "kota_supplier" => $row->kota_supplier,
                "kode_pos_supplier" => $row->kode_pos_supplier,
                "telepon_supplier" => $row->telepon_supplier,
                "fax_supplier"=> $row->fax_supplier,
                "email_supplier"=>$row->email_supplier,
                "attendance"=>$row->attendance,
                "id_supplier"=>$row->id_supplier,
                "nama_supplier"=>$row->nama_supplier
        ));

        if ($_SERVER["REQUEST_METHOD"] == "POST")
            echo $result;
        else
            return $result;
    }

    public function get_quotation_detil($kode) {
        $this->load->model('popup/quotationlist_model');

        $row = $this->quotationlist_model->getDetailQuotationlist($kode);

        $result = json_encode(array(
                "nama_customer" => $row->nama_customer,
                "alamat_komplit"=> $row->alamat_customer ."\n". $row->kota_customer."\n".$row->kode_pos_customer,
                "kontak_komplit"=> $row->telepon_customer." / ".$row->fax_customer." / ".$row->email_customer,
                "alamat_customer" => $row->alamat_customer,
                "alamat_detail_customer" => $row->alamat_detail_customer,
                "kota_customer" => $row->kota_customer,
                "kode_pos_customer" => $row->kode_pos_customer,
                "telepon_customer" => $row->telepon_customer,
                "fax_customer"=> $row->fax_customer,
                "email_customer"=>$row->email_customer,
                "attendance"=>$row->attendance
        ));

        if ($_SERVER["REQUEST_METHOD"] == "POST")
            echo $result;
        else
            return $result;
    }

    public function master_item() {
        $this->load->model('popup/item_model');

        $field_name = array("nama_item", "nama_port");
        $field_title = array("Nama Item", "PORT");
        $field_type = array("text", "text");

        $filter_panel = new FilterPanel(base_url() . 'index.php/', $field_name, $field_title, $field_type);
        $whr = $filter_panel->getFilterString();

        $offset = $this->input->get_post('os');
        $nextPage = $this->input->get_post('np');
        $colPage = $this->input->get_post('cp');

        if ($offset == "")
            $offset = 0;

        if ($nextPage == "")
            $nextPage = 1;

        if ($colPage == "")
            $colPage = 1;

        $result = $this->item_model->item_list($whr, PAGES_LIMIT, $offset);
        $numRowsAll = $this->item_model->count_item_list($whr);
        $data = array(
                "rows" => $result->num_rows(),
                "data" => $result->result(),
                "paging" => $this->paging->createPage($numRowsAll, $offset, PAGES_LIMIT, $nextPage, 10, $colPage),
                "offset" => $offset,
                "fp" => $filter_panel->drawfilterpanelsingle()
        );

        $this->log_event = "Membuka popup master item";

        $this->loadMenuHeaderPopup('popup/master_item', $data);
    }

    public function item_finalisasi() {
        $this->load->model('popup/item_model');

        $field_name = array("nama_item", "nama_port");
        $field_title = array("Nama Item", "PORT");
        $field_type = array("text", "text");

        $filter_panel = new FilterPanel(base_url() . 'index.php/', $field_name, $field_title, $field_type);
        $whr = $filter_panel->getFilterString();

        $offset = $this->input->get_post('os');
        $nextPage = $this->input->get_post('np');
        $colPage = $this->input->get_post('cp');

        if ($offset == "")
            $offset = 0;

        if ($nextPage == "")
            $nextPage = 1;

        if ($colPage == "")
            $colPage = 1;

        $result = $this->item_model->custom_item_list($whr, PAGES_LIMIT, $offset);
        $numRowsAll = $this->item_model->count_item_list($whr);
        $data = array(
                "rows" => $result->num_rows(),
                "data" => $result->result(),
                "paging" => $this->paging->createPage($numRowsAll, $offset, PAGES_LIMIT, $nextPage, 10, $colPage),
                "offset" => $offset,
                "fp" => $filter_panel->drawfilterpanelsingle()
        );

        $this->log_event = "Membuka popup master item";

        $this->loadMenuHeaderPopup('popup/finalisasi_item', $data);
    }

    public function item_finalisasi_dollar() {
        $this->load->model('popup/item_model');

        $field_name = array("nama_item", "nama_port");
        $field_title = array("Nama Item", "PORT");
        $field_type = array("text", "text");

        $filter_panel = new FilterPanel(base_url() . 'index.php/', $field_name, $field_title, $field_type);
        $whr = $filter_panel->getFilterString();

        $offset = $this->input->get_post('os');
        $nextPage = $this->input->get_post('np');
        $colPage = $this->input->get_post('cp');

        if ($offset == "")
            $offset = 0;

        if ($nextPage == "")
            $nextPage = 1;

        if ($colPage == "")
            $colPage = 1;

        $result = $this->item_model->custom_item_list($whr, PAGES_LIMIT, $offset);
        $numRowsAll = $this->item_model->count_item_list($whr);
        $data = array(
                "rows" => $result->num_rows(),
                "data" => $result->result(),
                "paging" => $this->paging->createPage($numRowsAll, $offset, PAGES_LIMIT, $nextPage, 10, $colPage),
                "offset" => $offset,
                "fp" => $filter_panel->drawfilterpanelsingle()
        );

        $this->log_event = "Membuka popup master item";

        $this->loadMenuHeaderPopup('popup/finalisasi_item_dollar', $data);
    }

    public function quotationlist() {
        $this->load->model('popup/quotationlist_model');

        $data = array();

        $field_name = array("nomor_quotation");
        $field_title = array("Nomor Quotation");
        $field_type = array("text");

        $filter_panel = new FilterPanel(base_url() . 'index.php/', $field_name, $field_title, $field_type);
        $whr = $filter_panel->getFilterString();

        $resultSet = $this->quotationlist_model->getQuotationlist($whr);
        $data['result'] = $resultSet->result();
        $data['numRows'] = $resultSet->num_rows();
        $data['fp'] = $filter_panel->drawfilterpanelsingle();

        $this->loadMenuHeaderPopup('/popup/quotationlist', $data);
    }

    public function polist() {
        $this->load->model('popup/polist_model');

        $data = array();

        $field_name = array("nomor_po");
        $field_title = array("Nomor PO");
        $field_type = array("text");

        $filter_panel = new FilterPanel(base_url() . 'index.php/', $field_name, $field_title, $field_type);
        $whr = $filter_panel->getFilterString();

        $resultSet = $this->polist_model->getPOlist($whr);
        $data['result'] = $resultSet->result();
        $data['numRows'] = $resultSet->num_rows();
        $data['fp'] = $filter_panel->drawfilterpanelsingle();

        $this->loadMenuHeaderPopup('/popup/polist', $data);
    }

    function get_quotation_item() {
        $this->load->model('popup/quotationlist_model');

        $id_quotation = $this->input->post("quot", true);

        $resultSet = $this->quotationlist_model->getItem($id_quotation);

        foreach($resultSet->result() as $row) {
            $result[] = array(
                    "item" => $row->id_item,
                    "nama" => $row->nama_item,
                    "satuan" => $row->satuan_beli,
                    "qty" => $row->quantity,
                    "harga_beli" => $row->harga_beli,
                    "harga_beli_dollar" => $row->harga_beli_dollar,
                    "price" => $row->harga_jual,
                    "total" => $row->harga_jual * $row->quantity,
                    "priced" => $row->harga_jual_dollar,
                    "totald" => $row->harga_jual_dollar * $row->quantity
            );
        }

        $result = json_encode($result);
        if ($_SERVER["REQUEST_METHOD"] == "POST")
            echo $result;
        else
            return $result;
    }

    function get_po_item() {
        $this->load->model('popup/polist_model');

        $id_po = $this->input->post("quot", true);

        $resultSet = $this->polist_model->getItem($id_po);

        foreach($resultSet->result() as $row) {
            $result[] = array(
                    "item" => $row->id_item,
                    "nama" => $row->nama_item,
                    "satuan" => $row->satuan_beli,
                    "qty" => $row->quantity,
                    "price" => $row->harga_jual,
                    "total" => $row->harga_jual * $row->quantity,
                    "priced" => $row->harga_jual_dollar,
                    "totald" => $row->harga_jual_dollar * $row->quantity
            );
        }

        $result = json_encode($result);
        if ($_SERVER["REQUEST_METHOD"] == "POST")
            echo $result;
        else
            return $result;
    }

    public function bank() {
        $this->load->model('popup/bank');

        $data = array();

        $resultSet = $this->bank->getBank();
        $data['result'] = $resultSet->result();
        $data['numRows'] = $resultSet->num_rows();

        $this->log_event = "Membuka popup daftar bank";

        $this->loadMenuHeaderPopup('/popup/bank', $data);
    }

}